import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GTileList } from "../../../../../com/mui/controls/GTileList";
import { ScrollPolicy } from "../../../../../fl/controls/ScrollPolicy";
import { DailyItemRenderer } from "../reward/DailyItemRenderer";
import { DataProvider } from "../../../../../fl/data/DataProvider";
type int = number;
//class ItemBgPanel
    
    export  class ItemBgPanel /* flash.display.Sprite */
    {
        constructor(arg1: int, arg2: int, arg3: int=43, arg4: int=43)
        {
            
            this._length = arg1;
            this._cols = arg2;
            this._rows = this._length / this._cols;
            this._spriteWidth = arg3;
            this._spriteHeight = arg4;
            this._listWidth = this._cols * this._spriteWidth;
            this._listHeight = this._rows * this._spriteHeight;
            this.initUI();
            mouseEnabled = false;
            return;
        }

        protected initUI(): void
        {
            var loc2=null;
            var loc1=0;
            while (loc1 < this._length) 
            {
                loc2 = GlobalClass.getBitmap(ImagesConst.PackItemBg);
                loc2.x = Math.floor(loc1 % this._cols) * this._spriteWidth;
                loc2.y = Math.floor(loc1 / this._cols) * this._spriteHeight;
                addChild(loc2);
                ++loc1;
            }
            this._itemList = new GTileList();
            this._itemList.rowHeight = this._spriteHeight;
            this._itemList.columnWidth = this._spriteWidth;
            this._itemList.horizontalGap = 0;
            this._itemList.verticalGap = 0;
            this._itemList.columnCount = this._cols;
            this._itemList.rowCount = this._rows;
            this._itemList.width = this._listWidth;
            this._itemList.height = this._listHeight;
            this._itemList.horizontalScrollPolicy = ScrollPolicy.OFF;
            this._itemList.verticalScrollPolicy = ScrollPolicy.OFF;
            this._itemList.setStyle("skin", new Object /* flash.display.Bitmap */());
            this._itemList.setStyle("cellRenderer", DailyItemRenderer);
            this._itemList.x = 3;
            this._itemList.y = 3;
            addChild(this._itemList);
            return;
        }

        public updateData(arg1: Array<any>): void
        {
            var loc1=0;
            var loc3=null;
            if (!this._dataProvider) 
            {
                this._dataProvider = new DataProvider();
            }
            this._dataProvider.removeAll();
            var loc2=arg1.length;
            while (loc1 < loc2) 
            {
                loc3 = arg1[loc1];
                this._dataProvider.addItem(loc3);
                ++loc1;
            }
            this._itemList.dataProvider = this._dataProvider;
            return;
        }

        public dispose(): void
        {
            if (this._dataProvider) 
            {
                this._dataProvider.removeAll();
                this._itemList.dataProvider = this._dataProvider;
            }
            return;
        }

        /* internal */ /* var */_length: int;

        /* internal */ /* var */_cols: int;

        /* internal */ /* var */_rows: int;

        /* internal */ /* var */_spriteWidth: int;

        /* internal */ /* var */_spriteHeight: int;

        /* internal */ /* var */_listWidth: int;

        /* internal */ /* var */_listHeight: int;

        protected /* var */_itemList: GTileList;

        protected /* var */_dataProvider: DataProvider;
    }
